package com.gh.yygh.hosp.controller;

import com.gh.yygh.common.result.Result;
import com.gh.yygh.hosp.service.HospitalService;
import com.gh.yygh.model.hosp.Hospital;
import com.gh.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "医院管理")
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    //查询医院列表(条件查询分页)
    @ApiOperation(value = "查询医院列表")
    @GetMapping("list/{page}/{limit}")
    public Result findPageHospital(@PathVariable("page") Integer page,
                                   @PathVariable("limit") Integer limit,
                                   HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pageModel = hospitalService.selectPageHospital(page,limit,hospitalQueryVo);
        System.out.println(pageModel);
        List<Hospital> content = pageModel.getContent();
        return Result.ok(pageModel);
    }

    //更新上线状态
    @ApiOperation(value = "更新上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result updateStatus(@PathVariable("id") String id, @PathVariable("status") Integer status){
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    //获取医院详情
    @ApiOperation(value = "获取医院详情")
    @GetMapping("show/{id}")
    public Result show(@PathVariable String id) {
        return Result.ok(hospitalService.show(id));
    }



}
